#include "Calendar.h"

static int Days[]={31,28,31,30,31,30,31,31,30,31,30,31};

Date::Date(int y,int m,int d)
{

	if(isry(y))Days[1]=29;
	else Days[1]=28;
	year=y;
	if(m>12||m<1)m=1;
	month=m;
	if(d<1||d>Days[m-1])d=1;
	return;
}

Date::Date(const Date &da)
{
	if(&da==this)return;
	year=da.year;
	month=da.month;
	day=da.day;

}


Date& Date::operator=(const Date &da)
{
	if(&da==this)return *this;
	year=da.year;
	month=da.month;
	day=da.day;
	return *this;
	
}

int Date::lastdate()
{
	if(isry(y))Days[1]=29;
	else Days[1]=28;
	int sd=0;
	for(int i=0;i<month-1;i++)
	{
		sd+=Days[i];
	}
	sd+=day;
	return sd;
}
int Date::shengxiao()
{
	return (year+9)%12;
}
Date& Date::operator+(int left)
{
	if(isry(y))Days[1]=29;
	else Days[1]=28;
	for(day+=left;day<=Days[month-1];)
	{
		day-=Days[month-1];
		month++;
	}
	return * this;
}
bool Date::operator>(Date & right)
{
	if(year>right.year)return true;
	if(year==right.year)
		if(month >right.month )return true;
		else if (month=right.month)
			if(day>right.day)return true;
	return false;
}